package com.zhou.org.common;

import com.alibaba.fastjson.JSON;
import com.zhou.util.StringTool;
import org.apache.commons.collections.MapUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class EnumConstant {
    //组织结构类型
    public static final Integer ORG_TYPE_USER = 1;
    public static final Integer ORG_TYPE_DEPART = 2;
    public static final Integer ORG_TYPE_ROLE = 3;

    public static final Map<String,Object> ORG_TYPE_MAP = JSON.parseObject("{user:1,dep:2,role:3}");

    public static List<Integer> getOrgTypes(String s){
        List<Integer> tps = new ArrayList<>(3);
        if(StringTool.isEmpty(s)){
            tps.add(ORG_TYPE_USER);
            tps.add(ORG_TYPE_DEPART);
            tps.add(ORG_TYPE_ROLE);
        }else{
            String[] arr = s.split("_");
            for(String a : arr){
                Integer t = MapUtils.getInteger(ORG_TYPE_MAP,a);
                if(t!= null){
                    tps.add(t);
                }
            }
        }

        return tps;
    }


    /** 是否菜单外链（是） */
    public static final Integer YES_FRAME = 0;

    /** 是否菜单外链（否） */
    public static final Integer NO_FRAME = 1;

    /** 菜单类型（目录） */
    public static final String TYPE_DIR = "M";

    /** 菜单类型（菜单） */
    public static final String TYPE_MENU = "C";

    /** 菜单类型（接口） */
    public static final String TYPE_INTF = "F";

    /** 菜单类型（按钮） */
    public static final String TYPE_BUTTON = "B";

    /** Layout组件标识 */
    public final static String LAYOUT = "Layout";

    /** ParentView组件标识 */
    public final static String PARENT_VIEW = "ParentView";

    /** InnerLink组件标识 */
    public final static String INNER_LINK = "InnerLink";

    /** 校验返回结果码 */
    public final static String UNIQUE = "0";
    public final static String NOT_UNIQUE = "1";


    public static final Integer ATTACH_TYPE_HEADER = 1;
    public static final Integer ATTACH_TYPE_MESSAGE = 2;

    //消息类型
    public static final Integer MSG_TYPE_NORMAL = 0;
    public static final Integer MSG_TYPE_EMAIL = 1;
    public static final Integer MSG_TYPE_OTHER = 2;

    //接收类型
    //接收
    public static final Integer MSG_RECEIVE_TYPE_NORMAL = 1;
    //抄送
    public static final Integer MSG_RECEIVE_TYPE_CC = 2;

    //消息详情发送状态;1-待发送;2-发送失败;3-发送成功
    public static final Integer MSG_DETAIL_SEND_STATUS_WAIT = 1;
    public static final Integer MSG_DETAIL_SEND_STATUS_FAIL = 2;
    public static final Integer MSG_DETAIL_SEND_STATUS_SUC = 3;
    //发送消息状态
    public static final Integer MSG_SEND_STATUS_WAIT = 1;
    public static final Integer MSG_SEND_STATUS_SUC = 2;
    public static final Integer MSG_SEND_STATUS_FAIL = 3;
    //部分成功
    public static final Integer MSG_SEND_STATUS_HALF = 4;

    //未读
    public static final Integer MSG_RECEIVE_SEND_STATUS_WAIT = 0;
    //已读
    public static final Integer MSG_RECEIVE_SEND_STATUS_READ = 1;
    //忽略
    public static final Integer MSG_RECEIVE_SEND_STATUS_IGNORE = 2;



}
